package leetcode.code0122;

import leetcode.helper.MaxDebug;

public class Solution extends Solution122 {

	@Override
	public int maxProfit(int[] prices) {
		int len = prices.length;
		if (len == 1)
			return 0;
		int ans = 0;
		int pre = prices[0];
		for (int i = 1; i < len; i++) {
			int num = prices[i];
			if (num > pre) {
				ans += num - pre;
				pre = num;
			} else {
				pre = num;
			}
		}
		return ans;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		MaxDebug.debug14(so);
	}

}
